"use strict";
module.exports = {
  /**
   * 获取待办详情
   * @url client/todo/kh/getTodoDetail 前端调用的url参数地址
   * data 请求参数
   * @param {String} params1  参数1
   */
  main: async (event) => {
    let { data = {}, userInfo, util, filterResponse, originalParam } = event;
    let { customUtil, uniID, config, pubFun, vk, db, _, $ } = util;
    let { uid } = data;
    // 业务逻辑开始-----------------------------------------------------------
    if (!data._id) {
      return { code: -1, msg: "缺少待办ID" };
    }
    let info = await vk.baseDao.selects({
      dbName: "dfb-todo",
      getCount: true,
      getMain: true,
      getOne: true,
      whereJson: { _id: data._id },
      // 主表字段显示规则
      fieldJson: {
        user_id: false,
      },
      foreignDB: [
        {
          dbName: "dfb-classification",
          localKey: "classification_id",
          foreignKey: "_id",
          as: "classification",
          limit: 1,
          fieldJson: {
            name: true,
          },
        },
      ],
    });
    if (!info) {
      return { code: -1, msg: "待办不存在" };
    }
    info.dateTime = info._add_time_str.substring(0, 16);
    delete info._add_time_str;
    // 业务逻辑结束-----------------------------------------------------------
    return { code: 0, msg: "获取成功", data: info };
  },
};
